local mansi = fk.CreateSkill{
  name = "wk_heg__mansi",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["wk_heg__mansi"] = "蛮嗣",
  [":wk_heg__mansi"] = "锁定技，【南蛮入侵】对你无效；每回合结束时，若本回合因【南蛮入侵】而受到伤害的角色数大于你的体力值，你复原此武将牌上所有技能。",

  ["$wk_heg__mansi1"] = "南蛮女子，该当英勇善战！",
  ["$wk_heg__mansi2"] = "蛮族的力量，你可不要小瞧！",
}

mansi:addEffect(fk.PreCardEffect, {
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(mansi.name) and data.card and data.card.trueName == "savage_assault" and player == data.to
  end,
  on_use = function(self, event, target, player, data)
    data.nullified = true
  end,
})

mansi:addEffect(fk.TurnEnd, {
  can_trigger = function (self, event, target, player, data)
    local events = player.room.logic:getActualDamageEvents(99, function(e)
      return e.data.card and e.data.card.trueName == "savage_assault"
    end, Player.HistoryTurn)
    return player:hasSkill(mansi.name) and #events > player.hp
  end,
  on_use = function(self, event, target, player, data)
    player:setSkillUseHistory("wk_heg__xiangzhen", 0, Player.HistoryGame)
  end,
})

return mansi

